<template>
  <div>
    <el-form label-width="120px" :model="form">
      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="支付模式" prop="payType">
            <el-select v-model="form.payType" style="width: 100%;">
              <el-option v-for="item in payOptions"
                         :key="item.value"
                         :label="item.label"
                         :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>

        </el-col>
        <el-col :span="12" v-if="form.payType===2">
          <el-form-item label="服务商Id" prop="platformId">
            <el-input v-model="form.platformId" name="platformId">
            </el-input>
          </el-form-item>

        </el-col>
        <el-col :span="12"  v-if="form.payType===2">
          <el-form-item label="服务商户号" prop="serviceMchId">
            <el-input v-model="form.serviceMchId" name="serviceMchId">
            </el-input>
          </el-form-item>

        </el-col>
        <el-col :span="12">
          <el-form-item label="appId" prop="appId">
            <el-input v-model="form.appId" name="appId">
            </el-input>
          </el-form-item>

        </el-col>
        <el-col :span="12">
          <el-form-item label="商户号" prop="mchId">
            <el-input v-model="form.mchId" name="mchId">
            </el-input>
          </el-form-item>

        </el-col>
        <el-col :span="12">
          <el-form-item label="商户Key" prop="mchKey">
            <el-input v-model="form.mchKey" name="mchKey">
            </el-input>
          </el-form-item>

        </el-col>
        <el-col :span="12">
          <el-form-item label="证书路径" prop="keyPath">
            <el-input v-model="form.keyPath" name="keyPath">
            </el-input>
          </el-form-item>

        </el-col>
        <el-col :span="24">
          <el-form-item label="通知Url" prop="notifyUrl">
            <el-input v-model="form.notifyUrl" name="notifyUrl">
            </el-input>
          </el-form-item>

        </el-col>
        <el-col :span="24">
          <el-form-item label="备注" prop="note">
            <el-input v-model="form.remark" name="note" type="textarea"></el-input>
          </el-form-item>

        </el-col>
      </el-row>
      <el-form-item>
        <el-button type="primary" @click="handleData">保存信息</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>

import nbSelect from "@/components/nbSelect.vue";

export default {
  components: {nbSelect},
  data() {
    return {
      payOptions: [
        {
          value: 1,
          label: '直连模式',
        },
        {
          value: 2,
          label: '服务商模式',
        }
      ],
      form: {
        tip: "",
        signNum: "",
        topicNum: ""
      },
      rules: {
        name: [{
          required: true,
          message: "请输入名称",
          trigger: "blur"
        }],
      },
    };
  },
  methods: {
    async handleData() {
      var self = this;
      var param = this.form;
      var res = await this.$http.form("/shopConfig/configWeChatPay", param);
      if (res.code == 200) {
        self.$message({
          message: "更新成功",
          type: "success",
        });
      } else {
        self.$message.error(res.msg);
      }
    },
    async loadData() {
      const res = await this.$http.form("/shopConfig/viewWeChatPay", {});
      if (res.code === 200) {
        this.form = res.data;
      }
    },
    changePoi(event) {
      console.log(event);
      this.form.lat = event.lat;
      this.form.lng = event.lng;
    },
  },
  mounted() {
    this.loadData();
  },
};
</script>

<style>
</style>
